home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d26 / drill.arc / MATH.BAS < prev    next >
Encoding:
BASIC Source File  |  1987-05-19  |  4.9 KB  |  125 lines

  1. 100 REM ** MATH.BAS ** CODEWORKS MAGAZINE, 3838 S. WARNER ST
  2. 110 REM ** TACOMA, WA 98409 ** (206) 475-2219 VOICE
  3. 120 REM ** (206) 475-2356 MODEM ** PLEASE DO NOT REMOVE THESE LINES.
  4. 130 REM * For conversion to 64 and 80 char screen PRINT@ and
  5. 140 REM * program notes see CodeWorks Issue 4
  6. 150 'CLEAR 1000: REM USE ONLY IF YOU NEED TO CLEAR STRING SPACE.
  7. 160 CLS
  8. 170 PRINT STRING$(22,"-");" The CodeWorks ";STRING$(23,"-")
  9. 180 PRINT"            M O V I N G   M A T H   P R O G R A M
  10. 190 PRINT"               Algebra in action, or AlgeCalc?
  11. 200 PRINT STRING$(60,"-")
  12. 210 PRINT"  This program contains three different mathematical equations"
  13. 220 PRINT"in which you can change various values interactively and"
  14. 230 PRINT"see the results while the computer solves the equation.
  15. 240 PRINT"  Pressing the upper case key for the letter variable in the
  16. 250 PRINT"formula will increase that value, lower case will decrease
  17. 260 PRINT"it. Pressing ENTER will return you to this menu.
  18. 270 PRINT
  19. 280 PRINT TAB(10);"1 - Compound Interest Formula"
  20. 290 PRINT TAB(10);"2 - Permutation Formula"
  21. 300 PRINT TAB(10);"3 - Resonant Frequency Formula"
  22. 310 PRINT"Your choice?";
  23. 320 X$=INKEY$:IF X$="" THEN GOTO 320
  24. 330 X=VAL(X$):IF X<>1 AND X<>2 AND X<>3 THEN GOTO 320
  25. 340 ON X GOTO 680,980,350
  26. 350 CLS
  27. 360 DEFDBL L,C,S,F
  28. 370 PRINT"             Resonant Frequency Formula"
  29. 380 PRINT
  30. 390 PRINT"Use F key to adjust rate of change, now = "
  31. 400 PRINT
  32. 410 PRINT"Where L is in Henrys, C is in Farads, 2xPI is constant and"
  33. 420 PRINT"f is the resonant frequency in cycles per second (Hertz)."
  34. 430 PRINT"          1"
  35. 440 PRINT"--------------------- = f (resonant)
  36. 450 PRINT"         /-----------
  37. 460 PRINT"2xPI x \/  L x C
  38. 470 PI=3.14159:SP=10
  39. 480 L=.0001
  40. 490 C=1E-07
  41. 500 IF C=<1E-09 THEN C=1E-09
  42. 510 IF L=<.000001 THEN L=.000001
  43. 520 IF SP<1 THEN SP=1
  44. 530 IF SP>100000! THEN SP=100000!
  45. 540 LOCATE 3,43,0:PRINT SP
  46. 550 S=L*C
  47. 560 S1=SQR(S)
  48. 570 F=1/(S1*(2*PI))
  49. 580 LOCATE 12,18:PRINT"1"
  50. 590 LOCATE 13,1:PRINT"----------------------------------- = ";:PRINT USING"###,#####.###";F;:PRINT"  Hertz"
  51. 600 LOCATE 14,1:PRINT"          /--------------------------"
  52. 610 LOCATE 15,1:PRINT"2xPI x  \/ ";:PRINT USING"#.######";L;:PRINT" x ";:PRINT USING"#.#########";C
  53. 620 K$=INKEY$:IF K$="" THEN GOTO 620
  54. 630 IF K$="L" THEN L=L+.000001*SP ELSE IF K$="l" THEN L=L-.000001*SP
  55. 640 IF K$="C" THEN C=C+1E-09*SP ELSE IF K$="c" THEN C=C-1E-09*SP
  56. 650 IF K$="F" THEN SP=SP*10 ELSE IF K$="f" THEN SP=SP/10
  57. 660 IF K$=CHR$(13) THEN RUN 100
  58. 670 GOTO 500
  59. 680 CLS
  60. 690 PRINT"            Compound Interest Formula"
  61. 700 PRINT
  62. 710 PRINT"Where P = Principal amount, I = Annual Interest Rate, Y is"
  63. 720 PRINT"number of years and C = number compounding periods per year."
  64. 730 PRINT
  65. 740 PRINT"Use F key to adjust rate of change, now = "
  66. 750 PRINT
  67. 760 PRINT"                     (Y x C)"              
  68. 770 PRINT"        P x (1 + I) ^          = Future Value"
  69. 780 P=1000
  70. 790 I=.05
  71. 800 C=4
  72. 810 Y=10
  73. 820 I1=I/C
  74. 830 IF SP>100000! THEN SP=100000!
  75. 840 IF SP<1 THEN SP=1
  76. 850 LOCATE 6,43:PRINT SP
  77. 860 N=Y*C
  78. 870 FV=P*((1+I1)^N)
  79. 880 LOCATE 13,1,0:PRINT"                      ";Y;" x ";C
  80. 890 LOCATE 14,1:PRINT USING"$$##,#####";P;:PRINT" x (1+";I;")^           = ";:PRINT USING "$$###,#####.##";FV
  81. 900 K$=INKEY$:IF K$="" THEN GOTO 900
  82. 910 IF K$="P" THEN P=P+1*SP ELSE IF K$="p" THEN P=P-1*SP:IF P<1 THEN P=0
  83. 920 IF K$="I" THEN I=I+.01 ELSE IF K$="i" THEN I=I-.01:IF I<.01 THEN I=.01
  84. 930 IF K$="C" THEN C=C+1*SP ELSE IF K$="c" THEN C=C-1*SP:IF C<1 THEN C=1
  85. 940 IF K$="Y" THEN Y=Y+1 ELSE IF K$="y" THEN Y=Y-1:IF Y<1 THEN Y=1
  86. 950 IF K$="F" THEN SP=SP*10 ELSE IF K$="f" THEN SP=SP/10
  87. 960 IF K$=CHR$(13) THEN RUN 100
  88. 970 GOTO 820
  89. 980 CLS
  90. 990 PRINT"             Permutation Formula"
  91. 1000 PRINT
  92. 1010 PRINT"How many ways can (R) items within a"
  93. 1020 PRINT"larger group (N) be arranged?"
  94. 1030 PRINT"P is the answer."
  95. 1040 PRINT
  96. 1050 PRINT"              N!
  97. 1060 PRINT"    -----------------------  = P
  98. 1070 PRINT"          ( N - R )!
  99. 1080 PRINT
  100. 1090 N=7
  101. 1100 R=5
  102. 1110 IF N<2 THEN N=2     : ' GOTTA HAVE 2 TO ARRANGE ANYTHING
  103. 1120 IF N>32 THEN N=32   : ' CAUSES OVERFLOW IF MORE
  104. 1130 IF R<1 THEN R=1     : ' MUST HAVE AT LEAST ONE ITEM
  105. 1140 IF R=>N-1 THEN R=N-1: ' CAN'T ARRANGE MORE THAN YOU HAVE
  106. 1150 T=N-R:N1=N
  107. 1160 FOR I=1 TO N1-1     : ' FACTORIAL TAKES PLACE HERE 
  108. 1170 N1=N1*I
  109. 1180 NEXT I
  110. 1190 IF T<1 THEN T=1:GOTO 1230
  111. 1200 FOR I=1 TO T-1      : ' FACTORIAL TAKES PLACE HERE TOO
  112. 1210 T=T*I
  113. 1220 NEXT I
  114. 1230 P=N1/T
  115. 1240 LOCATE 11,1,0:PRINT"      ";N;"!      ";N1
  116. 1250 LOCATE 12,1:PRINT" ------------ = -------------- =";P
  117. 1260 LOCATE 13,1:PRINT"  (";N;"-";R;")!    ";T
  118. 1270 K$=INKEY$:IF K$="" THEN GOTO 1270
  119. 1280 IF K$="N" THEN N=N+1 ELSE IF K$="n" THEN N=N-1
  120. 1290 IF K$="R" THEN R=R+1 ELSE IF K$="r" THEN R=R-1
  121. 1300 IF K$=CHR$(13) THEN RUN 100
  122. 1310 GOTO 1110
  123. E IF K$="n" THEN N=N-1
  124. 1290 IF K$="R" THEN R=R+1 ELSE IF K$="r" THEN R=R-1
  125. 1300 IF K$=CHR$(13) TH